package com.puge.eduservice.controller;


import com.puge.commonutils.R;
import com.puge.eduservice.entity.subject.OneSubject;
import com.puge.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-06-13
 */
@Api(description = "课程添加")//设置接口文档名称
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

//    添加课程分类
//    获取上传过来的文件，把文件内容读取出来
    @ApiOperation("表格插入数据")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
//        上传过来的excel文件
        subjectService.saveSubject(file,subjectService);

        return R.ok();
    }

//    课程分类列表(树形)
    @GetMapping("getAllSubject")
    public R getAllSubject(){
        List<OneSubject>  list = subjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);

    }
}

